﻿package com.firewolf.spring.transaction.annotation;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/***
 * 批量买多次书的服务
 * @author liuxing
 *
 */
@Service("batchService")
public class BatchBookShopService {
	
	@Autowired
	private BookShopService bookShopService = null;
	
	/**
	 * 批量买书
	 * @param userName
	 * @param booksIds
	 */
	@Transactional
	public void bacthBuyBooks(String userName,List<String> bookIds){
		for(String bookId : bookIds){
			/**这里调用了多个事务*/
			bookShopService.buyBook(bookId, userName);
		}
	}
}
